package com.luocj.muke.demo.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v4.app.FragmentActivity;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.luocj.muke.demo.R;

import org.w3c.dom.Text;

import java.util.ArrayList;

public class TestBAdapter extends RecyclerView.Adapter<TestBAdapter.Holder> {

    private ArrayList<String> mDatas = new ArrayList<>();
    private Context mContext;

    public TestBAdapter(Context context, ArrayList<String> data) {
        this.mDatas = data;
        this.mContext = context;

    }

    @NonNull
    @Override
    public Holder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View inflate = LayoutInflater.from(mContext).inflate(R.layout.item_text, parent, false);
        Holder holder = new Holder(inflate);
        return holder;
    }

    @Override
    public void onBindViewHolder(@NonNull Holder holder, int position) {
        holder.textview.setText(mDatas.get(position));
    }

    @Override
    public int getItemCount() {
        return mDatas.size();
    }

    public class Holder extends RecyclerView.ViewHolder {
        TextView textview;

        public Holder(View itemView) {
            super(itemView);
            textview = itemView.findViewById(R.id.tv_text);
        }
    }
}
